import {VNode} from "snabbdom/src/package/vnode";

let ConfigureElementForVNode = (a:VNode) => {
    let sel = a.sel;
    let elementName = '';
    if (sel.indexOf('#') !== -1) {
        elementName = sel.substr(sel.indexOf('#'));
    } else if (sel.indexOf('.') !== -1) {
        elementName = sel.substr(sel.indexOf('.'));
    }

    if (elementName !== '') {
        let elm = document.querySelector(elementName);
        a.elm = elm;
    }

    let children = a.children;
    children && children.forEach(c => {
        if (c instanceof Object) ConfigureElementForVNode(c);
    })
};

export {ConfigureElementForVNode};